/*
 * flash.h
 *
 * Created: 17/01/2014 11:11:25
 *  Author: usuario
 */ 


#ifndef FLASH_H_
#define FLASH_H_

#include <asf.h>
#include <rtos.h>

#define FLASH_SIZE		4096


/* Internal Flash 0 base address. */
#define IFLASH_ADDR			IFLASH0_ADDR
/* Internal flash page size. */
#define IFLASH_PAGE_SIZE    IFLASH0_PAGE_SIZE
/* Last page start address. */
#define LAST_PAGE_ADDRESS	(IFLASH1_ADDR + IFLASH1_SIZE - IFLASH1_PAGE_SIZE)

#define FLASH_ADDR			( IFLASH1_ADDR + IFLASH1_SIZE - FLASH_SIZE   )
#define FLASH_LAST_ADDR		( IFLASH1_ADDR + IFLASH1_SIZE -1 )


void FLASH_setup( void );

uint8_t flash_write_block (const void *__src, void *__dst, size_t __n);
uint8_t flash_read_block (void *__dst, const void *__src, size_t __n);


#endif /* FLASH_H_ */